#include "dlgstandards.h"
#include "dblDele.h"
//#include "trackdelegate.h"
Dlgstandards::Dlgstandards(ApplicationWindow *parent)
    : QDialog(parent)
{
        ui.setupUi(this);
        model = new QSqlRelationalTableModel(this);
        model->setTable("standard");
        model->select();
        ui.tableView->setModel(model);
        ui.tableView->setSortingEnabled(true);
        QStringList list;
        list << "A" << "B" << "C";

        // 创建时指定数据传入
//        TrackDelegate *m_cBoxDelegate = new TrackDelegate();
        DoubleDelegate *m_cBoxDelegate = new DoubleDelegate();
//        ui.tableView->setItemDelegate(m_cBoxDelegate);
        ui.tableView->setItemDelegateForColumn(2, m_cBoxDelegate);
        ui.tableView->setItemDelegateForColumn(3, m_cBoxDelegate);
}
void Dlgstandards::on_pushButton_add_clicked()
{
    model->insertRow(0);
}
void Dlgstandards::on_pushButton_delete_clicked()
{
    QModelIndex  current=this->ui.tableView->currentIndex ();
    int row=current.row();
    model->removeRow(row);
}
void Dlgstandards::accept()
{
        qDebug("accept");
        model->submitAll();
        QDialog::accept();
}
void Dlgstandards::reject()
{
        qDebug("reject");
        QDialog::reject();

}

Dlgstandards::~Dlgstandards()
{

}
